/*
 * Copyright (c) Jiandong.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */

export class PixelUtil {

  /** Convert from DIP to PX */
  public static toPixelFromDIP(value: number): number {
    //  return TypedValue.applyDimension(
    //  TypedValue.COMPLEX_UNIT_DIP, value, DisplayMetricsHolder.getWindowDisplayMetrics());
      return value;
  }

  ///** Convert from DIP to PX */
  //public static toPixelFromDIP(value: number): number {
  //  return toPixelFromDIP((float) value);
  //}

  ///** Convert from SP to PX */
  //public static float toPixelFromSP(float value) {
  //  return toPixelFromSP(value, Float.NaN);
  //}

  /** Convert from SP to PX */
  public static toPixelFromSP(value: number, maxFontScale: number = undefined): number {
  //    DisplayMetrics displayMetrics = DisplayMetricsHolder.getWindowDisplayMetrics();
        let scaledDensity: number = 1// = displayMetrics.scaledDensity;
  //    float currentFontScale = scaledDensity / displayMetrics.density;
  //    if (maxFontScale >= 1 && maxFontScale < currentFontScale) {
  //      scaledDensity = displayMetrics.density * maxFontScale;
  //    }

      return value * scaledDensity;
  }

  ///** Convert from SP to PX */
  //public static toPixelFromSP(value: number)：number  {
  //  return toPixelFromSP((float) value);
  //}

  /** Convert from PX to DP */
  public static toDIPFromPixel(value: number): number {
    return value;
  //  return value / DisplayMetricsHolder.getWindowDisplayMetrics().density;
  }

/** @return {@link float} that represents the density of the display metrics for device screen. */
  public static getDisplayMetricDensity(): number {
     return 1;
  //  return DisplayMetricsHolder.getWindowDisplayMetrics().density;
  }
}
